package com.xhui.vimarket.zkplus.zul.attr.bus.impl;

import org.zkoss.zk.ui.Component;

import com.xhui.crm.common.vo.RetVO;com.xhui.vimarket.zkplusui.vimarket.zkplus.zul.attr.buscom.xhui.vimarket.zkplusrt com.xhui.vimarket.zkplus.zul.attr.buscom.xhui.vimarket.zkplusts;
import com.xhui.vimarket.zcom.xhui.vimarket.zkplusbus.AttrFun;
import com.xhui.vimarket.zkplcom.xhui.vimarket.zkplus.IAttrBusDivComposer;
import com.xhui.vimarkcom.xhui.vimarket.zkplusttr.evt.AttrDivExtDivComposer;
import cocom.xhui.vimarket.zkplus.zkplus.zul.attr.mod.impl.AttrBaseComp;
import com.xhui.vimarket.zkplus.zul.attr.util.AttrUtil;

/**
 * .
 * 
 * @版权：福富软件 版权所有 (c) 2011
 * @author wuyx
 * @version Revision 1.0.0
 * @see:
 * @创建日期：2012-1-16
 * @功能说明：
 * 
 */
public class AttrBusDivComposer extends AttrDivExtDivComposer implements IAttrBusDivComposer {
    
    /**
     * serialVersionUID.
     */
    private static final long serialVersionUID = 1L;
    
    /**
     * attrBus.
     */
    private AttrBcom.xhui.vimarket.zkplustrBus;
    
    /**
     * {@inheritDoc}
     * @see com.xhui.vimarket.zkplus.zul.attr.bus.IAttrBusDivComposer
     * #fireProcListener(java.lang.String, java.lang.Object)
     * @author wuyx
     * 2012-1-17 wuyx
     */
    @Override
    public void fireProcListener(String procName, Object obj) {
        if (this.attrBus == null) {
            this.attrBus = AttrUtil.getAttrBus(this.self);
        }
        this.attrBus.fireProcLcom.xhui.vimarket.zkpluse, obj);
    }
    
    /**
     * {@inheritDoc}
     * @see com.xhui.vcom.xhui.vimarket.zkpluszul.attr.bus.IAttrBusDivComposer
     * #addFunListener(java.lang.String, com.xhui.vimarket.zkplus.zul.attr.bus.AttrFun)
     * @author wuyx
     * 2012-1-17 wuyx
     */
    public void addFunListener(String funName, AttrFun attrFun) {
        if (this.attrBus == null) {
            this.attrBus = AttrUtil.getAttrBus(this.self);
        }
        this.attrBus.addFunListener(funName, attrFun);
    }
    
    /**
     * init.
     * 
     * @param comp
     *            Component
     */
    public void init(final Component comp) {
        // 控件编码
        String extCode = comp.getParent().getAttribute(AttrBaseComp.COMP_COMPCODE) + "";
        
        // 显示控件        
        AttrFun funShowComp = new AttrFun() {
            public RetVO call(Object obj) {
                AttrBusDivComposer.this.self.getParent().setVisible(true);
                return null;
            }
        };
        this.addFunListener(AttrBusConstants.FUN_COMM_SHOW_PRE + extCode, funShowComp);
        
        // 隐藏控件        
        AttrFun funHideComp = new AttrFun() {
            public RetVO call(Object obj) {
                AttrBusDivComposer.this.self.getParent().setVisible(false);
                return null;
            }
        };
        this.addFunListener(AttrBusConstants.FUN_COMM_HIDE_PRE + extCode, funHideComp);
    }

}
